package com.shanzhu.volunteer.interfaces.controller.admin.volunteer;

import com.shanzhu.volunteer.common.component.page.TableDataInfo;
import com.shanzhu.volunteer.common.entity.Response;
import com.shanzhu.volunteer.interfaces.body.volunteer.profession.ProfessionBody;
import com.shanzhu.volunteer.interfaces.controller.BaseController;
import com.shanzhu.volunteer.modules.volunteer.entity.model.CeProfession;
import com.shanzhu.volunteer.modules.volunteer.service.CeProfessionService;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * 专业查询管理
 *
 * @author: ShanZhu
 * @date: 2023-03-31 16:40:29
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/college_entrance/profession")
public class CeProfessionController extends BaseController {

    private final CeProfessionService professionService;

    /**
     * 请求专业列表
     *
     * @param professionBody 专业请求体
     * @return 专业列表
     */
    @ApiOperation(value = "请求专业列表")
    @GetMapping("/list")
    public TableDataInfo list(ProfessionBody professionBody) {
        startPage();
        return getDataTable(professionService.selectProfessionList(professionBody));
    }

    /**
     * 添加专业
     *
     * @param professionBody 专业请求体
     * @return 结果
     */
    @ApiOperation(value = "添加专业")
    @PostMapping
    public Response<Boolean> add(@RequestBody ProfessionBody professionBody) {
        return professionService.addProfession(professionBody);
    }

    /**
     * 编辑专业
     *
     * @param professionBody 专业请求体
     * @return 结果
     */
    @ApiOperation(value = "编辑院校")
    @PutMapping
    public Response<Boolean> edit(@RequestBody ProfessionBody professionBody) {
        return professionService.editProfession(professionBody);
    }

    /**
     * 通过专业id查询专业信息
     *
     * @param professionId 专业id
     * @return 结果
     */
    @ApiOperation(value = "通过专业id查询专业信息")
    @GetMapping("/{professionId}")
    public Response<CeProfession> getInfo(@PathVariable Integer professionId) {
        return new Response<>(professionService.getProfession(professionId));
    }

    /**
     * 删除专业
     *
     * @param professionIds 专业id列表
     * @return 结果
     */
    @ApiOperation(value = "专业id列表")
    @DeleteMapping("/{professionIds}")
    public Response<Boolean> remove(@PathVariable Integer[] professionIds) {
        return professionService.deleteProfessionIds(professionIds);
    }

}

  